/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

/**
 *
 * @author BENSON
 */
public class ControllerPrintTicket {
    /**
     * variable and views declarations
     */
    
    String  selected;
    Views.printTicket printTick;
    Model.MainModel model;
    private ActionListener actionListener;
    
    
    /**
     * Default constructor for instantiating declared objects and views
     */
public ControllerPrintTicket( String key){
        printTick = new Views.printTicket();
        printTick.setVisible(true);
        model=new Model.MainModel();
        selected=key;
} 
    
    /**
     * Method to add action listener to clicked buttons 
      */

public void control(){       
        actionListener = new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==printTick.getPrintBtn()){
                     model.printTicketSelectedPatient(printTick,selected);
                  }
                  if(actionEvent.getSource()==printTick.getCloseBtn()){
                  printTick.setVisible(false);
                  
                  }
               }
              
        };                
        printTick.getPrintBtn().addActionListener(actionListener);
        printTick.getCloseBtn().addActionListener(actionListener);
        
}
    
}
